/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package biofilter.records.NimbleGen;

import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import biofilter.records.RecordBase;
import biofilter.exceptions.InvalidRecordException;
import biofilter.util.StringUtil;

/**
 *
 * @author Daniel Quest
 * @date   Dec 16th 2009
 */
public class NimbleGenNDFRecord extends RecordBase {


    public NimbleGenNDFRecord() {
        this.parsed = false;
        setup();
    }

    public NimbleGenNDFRecord(String line) {
        this.record = line;
        setup();
        set(line);
    }

    public void setup(){
        u = new StringUtil();
    }

    String record = "";
    static StringUtil u = null;
    /**
     * This record serves to give us the array design
     * Example:
     * PROBE_DESIGN_ID CONTAINER       DESIGN_NOTE     SELECTION_CRITERIA      SEQ_ID  PROBE_SEQUENCE  MISMATCH        MATCH_INDEX     FEATURE_ID      ROW_NUM COL_NUM PROBE_CLASS     PROBE_ID        POSITION        DESIGN_ID       X       Y
       10425_0001_0001 NGS_CONTROLS    crosshhybe      bright  CROSSHYBE       TAGCGTTGCTTAGGCGTACGCAGTCTGATGCGTCGTTAGCATCGGCAANNNNNNNNNN      0       241440130       241440130       1       1       control:crosshybe       XENOTRACK48P01  1       10425   1       1
     */
    private boolean parsed;
    private String probe_Design_ID;
    private String container;
    private String designNote;
    private String selectionCriteria;
    private String seqID;
    private String probeSequence;
    private int mismatch;
    private int matchIndex;
    private int featureID;
    private int rowNum;
    private int colNum;
    private String probeClass;
    private String probeID;
    private int position;
    private int designID;
    private int x;
    private int y;
    public String get(){ return record; }
    public void set(String s){ 
            this.record = s;
            this.parsed = false;
    }
    public void parse() throws InvalidRecordException {
        String line = this.record;
        //System.err.println(line);
        String cols[] = null;
        if (line.length() < 17){
            throw new InvalidRecordException("KB.Records.NimbleGen.NimbleGenRaw: no record found: " + line);
        }
        try {
             //System.err.println("Calling split on spaces! " + line);
             cols = u.splitOnTab(line, 17);
        } catch (ParseException ex) {
             Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, line, ex);
        }
        Double dd = new Double("0");
        Integer ll = new Integer("1");
        if ( cols.length == 17){
            
            probe_Design_ID= cols[0];
            container = cols[1];
            designNote = cols[2];
            selectionCriteria = cols[3];
            seqID = cols[4];
            probeSequence = cols[5];
            mismatch = ll.parseInt(cols[6]);
            matchIndex = ll.parseInt(cols[7]);
            featureID = ll.parseInt(cols[8]);
            rowNum = ll.parseInt(cols[9]);
            colNum = ll.parseInt(cols[10]);
            probeClass = cols[11];
            probeID = cols[12];
            position = ll.parseInt(cols[13]);;
            designID = ll.parseInt(cols[14]);
            //System.err.println(cols[16]);
            x = ll.parseInt(cols[15]);
            y = ll.parseInt(cols[16]);
        }else{
             throw new InvalidRecordException("KB.Records.NimbleGen.NimbleGenRaw: set malformed record: " + line);
        }
    }

    public int getColNum() {
        if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return colNum;
    }

    public void setColNum(int colNum) {
        this.colNum = colNum;
    }

    public String getContainer() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return container;
    }

    public void setContainer(String container) {
        this.container = container;
    }

    public int getDesignID() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return designID;
    }

    public void setDesignID(int designID) {
        this.designID = designID;
    }

    public String getDesignNote() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return designNote;
    }

    public void setDesignNote(String designNote) {
        this.designNote = designNote;
    }

    public int getFeatureID() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return featureID;
    }

    public void setFeatureID(int featureID) {
        this.featureID = featureID;
    }

    public int getMatchIndex() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return matchIndex;
    }

    public void setMatchIndex(int matchIndex) {
        this.matchIndex = matchIndex;
    }

    public int getMismatch() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return mismatch;
    }

    public void setMismatch(int mismatch) {
        this.mismatch = mismatch;
    }

    public int getPosition() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    public String getProbeClass() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return probeClass;
    }

    public void setProbeClass(String probeClass) {
        this.probeClass = probeClass;
    }

    public String getProbeID() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return probeID;
    }

    public void setProbeID(String probeID) {
        this.probeID = probeID;
    }

    public String getProbeSequence() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return probeSequence;
    }

    public void setProbeSequence(String probeSequence) {
        this.probeSequence = probeSequence;
    }

    public String getProbe_Design_ID() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return probe_Design_ID;
    }

    public void setProbe_Design_ID(String probe_Design_ID) {
        this.probe_Design_ID = probe_Design_ID;
    }

    public int getRowNum() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return rowNum;
    }

    public void setRowNum(int rowNum) {
        this.rowNum = rowNum;
    }

    public String getSelectionCriteria() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return selectionCriteria;
    }

    public void setSelectionCriteria(String selectionCriteria) {
        this.selectionCriteria = selectionCriteria;
    }

    public String getSeqID() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return seqID;
    }

    public void setSeqID(String seqID) {
        this.seqID = seqID;
    }

    public int getX() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
                if(this.parsed == false){
            try {
                parse();
                this.parsed = true;
            } catch (InvalidRecordException ex) {
                Logger.getLogger(NimbleGenNDFRecord.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    


}
